package com.dyz.leetcode._05_sort;

import java.util.Arrays;
import java.util.Comparator;

public class _179_largestNumber {
    public String largestNumber(int[] nums) {

        String [] strs= new String[nums.length];
        for(int i=0; i<nums.length;i++){
            strs[i] = ""+nums[i];
        }

        Arrays.sort(strs, new Comparator<String>() {
            @Override
            public int compare(String x, String y) {
                String xy = x+y;
                String yx = y+x;
                return yx.compareTo(xy);
            }
        });

        if(nums[0]==0){return "0";}

        StringBuilder res = new StringBuilder();
        for(String str:strs){
            res.append(str);
        }
        return res.toString();
    }

    //自定义快排



    public static void main(String[] args) {
        int[]nums = new int[]{0,0};
        String s = new _179_largestNumber().largestNumber(nums);
        System.out.println(s);
    }
}
